﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using NursingFormSystem.Model;
using DLL;
using Common;
using NursingFormSystem.Common;
using SQLDLL;
using NursingFormSystem;

namespace NursingFormSystem.RiskAssessment
{
    public partial class AddRiskSoreNursing : DevExpress.XtraEditors.XtraForm
    {
        #region 变量声明
        Tb_User LoginUser;
        NursingFormRecord record = new NursingFormRecord();
        NurFormsService.NursingForm formService = new NurFormsService.NursingForm();
        PatientInfo PatientInfo;
        string Id = string.Empty;
        ElectronicSignature es;
        #endregion

        #region 窗体构造函数2个 内部和外部使用
        public AddRiskSoreNursing(Tb_User loginUser, PatientInfo patientInfo, string id)
        {
            InitializeComponent();
            //构造参数赋值
            this.LoginUser = loginUser;
            this.PatientInfo = patientInfo;
            this.Id = id;

            es = new ElectronicSignature(LoginUser);//电签实例化

            //绑定数据
            BindInfo(id);
        }
                public AddRiskSoreNursing(string[] loginUser, string[] patientInfo)
        {
            InitializeComponent();
            //构造参数赋值
            this.LoginUser = ArrayToObject.ArrayToLoginUser(loginUser);
            this.PatientInfo = ArrayToObject.ArrayToPatientInfo(patientInfo);
            this.Id = string.Empty;

            es = new ElectronicSignature(LoginUser);//电签实例化

            //绑定数据
            BindInfo(this.Id);
        }
        public AddRiskSoreNursing(string[] loginUser, string[] patientInfo, string id)
        {
            InitializeComponent();
            //构造参数赋值
            this.LoginUser = ArrayToObject.ArrayToLoginUser(loginUser);
            this.PatientInfo = ArrayToObject.ArrayToPatientInfo(patientInfo);
            this.Id = id;

            es = new ElectronicSignature(LoginUser);//电签实例化

            //绑定数据
            BindInfo(this.Id);
        }
        #endregion

        #region 显示赋值
        public void BindInfo(string Id)
        {
            dateE_AssDate.DateTime = DateTime.Now; // 默认显示当前日期 
            if (string.IsNullOrEmpty(Id)) return;
            string sql = string.Format(@" SELECT TOP 1 NursingFormData FROM NursingFormRecord(NOLOCK) WHERE Id='{0}' ", Id);
            var NursingFormData = SqlHelper.ExecuteScalar(sql).ToString();
            RiskSore ps = new RiskSore();
            ps = XmlUtil.XMLToObject<RiskSore>(NursingFormData, Encoding.UTF8);
            txtjiashu.Text = ps.HuanZheQianZi;//患者或家属签名
            comboBoxEdityhzgx.EditValue = ps.YuHuanZheGuanXi;//与患者关系
            txtSituation.Text = ps.HuanZhePiFuQingGuang;//皮肤情况
            dateE_AssDate.DateTime = Convert.ToDateTime(ps.PingGuRiQi);//评估日期
            //感觉
            if (ps.GanJue == "4")
                radFeel.SelectedIndex = 0;
            else if (ps.GanJue == "3")
                radFeel.SelectedIndex = 1;
            else if (ps.GanJue == "2")
                radFeel.SelectedIndex = 2;
            else if (ps.GanJue == "1")
                radFeel.SelectedIndex = 3;
            else
                radFeel.SelectedIndex = -1;
            //潮湿
            if (ps.ChaoShi == "4")
                radDamp.SelectedIndex = 0;
            else if (ps.ChaoShi == "3")
                radDamp.SelectedIndex = 1;
            else if (ps.ChaoShi == "2")
                radDamp.SelectedIndex = 2;
            else if (ps.ChaoShi == "1")
                radDamp.SelectedIndex = 3;
            else
                radDamp.SelectedIndex = -1;
            //活动力
            if (ps.HuoDongLi == "4")
                radActivity.SelectedIndex = 0;
            else if (ps.HuoDongLi == "3")
                radActivity.SelectedIndex = 1;
            else if (ps.HuoDongLi == "2")
                radActivity.SelectedIndex = 2;
            else if (ps.HuoDongLi == "1")
                radActivity.SelectedIndex = 3;
            else
                radActivity.SelectedIndex = -1;
            //移动力
            if (ps.YiDongLi == "4")
                radMove.SelectedIndex = 0;
            else if (ps.YiDongLi == "3")
                radMove.SelectedIndex = 1;
            else if (ps.YiDongLi == "2")
                radMove.SelectedIndex = 2;
            else if (ps.YiDongLi == "1")
                radMove.SelectedIndex = 3;
            else
                radMove.SelectedIndex = -1;
            //摩擦力和剪切力
            if (ps.MoChaLiHeJianQieLi == "3")
                radFriction.SelectedIndex = 0;
            else if (ps.MoChaLiHeJianQieLi == "2")
                radFriction.SelectedIndex = 1;
            else if (ps.MoChaLiHeJianQieLi == "1")
                radFriction.SelectedIndex = 2;
            else
                radFriction.SelectedIndex = -1;
            //营养
            if (ps.YingYang == "4")
                radNutrition.SelectedIndex = 0;
            else if (ps.YingYang == "3")
                radNutrition.SelectedIndex = 1;
            else if (ps.YingYang == "2")
                radNutrition.SelectedIndex = 2;
            else if (ps.YingYang == "1")
                radNutrition.SelectedIndex = 3;
            else
                radNutrition.SelectedIndex = -1;
            //体位安置与变换
            var PosturalPlacement = ps.TiWeiAnZhiYuBianHuan.Split('#');
            cheTiwei1.Checked = (PosturalPlacement[0] == "1");
            cheTiwei2.Checked = (PosturalPlacement[1] == "1");
            cheTiwei3.Checked = (PosturalPlacement[2] == "1");
            cheTiwei4.Checked = (PosturalPlacement[3] == "1");
            cheTiwei5.Checked = (PosturalPlacement[4] == "1");
            cheTiwei6.Checked = (PosturalPlacement[5] == "1");
            //减压用具与使用
            var Decompression = ps.JianYaYongJuYuShiYong.Split('#');

            cheJianya1.Checked = (Decompression[0] == "1");
            cheJianya2.Checked = (Decompression[1] == "1");
            cheJianya3.Checked = (Decompression[2] == "1");
            cheJianya4.Checked = (Decompression[3] == "1");
            //皮肤护理
            var SkinCare = ps.PiFuHuLi.Split('#');
            chePifu1.Checked = (SkinCare[0] == "1");
            chePifu2.Checked = (SkinCare[1] == "1");
            chePifu3.Checked = (SkinCare[2] == "1");
            chePifu4.Checked = (SkinCare[3] == "1");
            chePifu5.Checked = (SkinCare[4] == "1");
            chePifu6.Checked = (SkinCare[5] == "1");
            //营养支持
            var NutritionSupport = ps.YingYangZhiChi.Split('#');
            cheYingyang1.Checked = (NutritionSupport[0] == "1");
            cheYingyang2.Checked = (NutritionSupport[1] == "1");
            cheYingyang3.Checked = (NutritionSupport[2] == "1");
            cheYingyang4.Checked = (NutritionSupport[3] == "1");
            txtNurse.Text = ps.HuShiQianMing;//护士签字
            txtNurseZ.Text = ps.HuShiZhangQianMing;//护士长签字
            //护士签字-电签
            es.SetSiginPic(LoginUser.DepartmentCode, ps.HuShiQianMing_ID, picElectronicSignature, txtNurse.Location, txtNurse);
            if (txtNurse.Text.Equals(this.LoginUser.UserName)) txtNurseId = true;
            //护士长签字-电签
            es.SetSiginPic(LoginUser.DepartmentCode, ps.HuShiZhangQianMing_ID, pictureBox1, txtNurseZ.Location, txtNurseZ);
            if (txtNurseZ.Text.Equals(this.LoginUser.UserName)) txtNurseZId = true;
            //预后
            var Prognosis = ps.YuHou.Split('#');
            cheYuhou1.Checked = (Prognosis[0] == "1");
            cheYuhou2.Checked = (Prognosis[1] == "1");
            cheYuhou3.Checked = (Prognosis[2] == "1");
            cheYuhou4.Checked = (Prognosis[3] == "1");
            cheYuhou5.Checked = (Prognosis[4] == "1");
            cheYuhou6.Checked = (Prognosis[5] == "1");
            txtScoreTotal.Text = ps.ZongFen.ToString();//总分
        }
        #endregion

        #region 计算分值
        public void SunTotal()
        {
            int Sum = 0;
            int Total = 0;
            int Total1 = 0;
            int Total2 = 0;
            int Total3 = 0;
            int Total4 = 0;
            int Total5 = 0;
            //感觉
            if (radFeel.SelectedIndex == 0)
                Total = 4;
            else if (radFeel.SelectedIndex == 1)
                Total = 3;
            else if (radFeel.SelectedIndex == 2)
                Total = 2;
            else if (radFeel.SelectedIndex == 3)
                Total = 1;
            else
                Total = 0;
            //潮湿
            if (radDamp.SelectedIndex == 0)
                Total1 = 4;
            else if (radDamp.SelectedIndex == 1)
                Total1 = 3;
            else if (radDamp.SelectedIndex == 2)
                Total1 = 2;
            else if (radDamp.SelectedIndex == 3)
                Total1 = 1;
            else
                Total1 = 0;
            //活动力
            if (radActivity.SelectedIndex == 0)
                Total2 = 4;
            else if (radActivity.SelectedIndex == 1)
                Total2 = 3;
            else if (radActivity.SelectedIndex == 2)
                Total2 = 2;
            else if (radActivity.SelectedIndex == 3)
                Total2 = 1;
            else
                Total2 = 0;
            //移动力
            if (radMove.SelectedIndex == 0)
                Total3 = 4;
            else if (radMove.SelectedIndex == 1)
                Total3 = 3;
            else if (radMove.SelectedIndex == 2)
                Total3 = 2;
            else if (radMove.SelectedIndex == 3)
                Total3 = 1;
            else
                Total3 = 0;
            //摩擦力和剪切力
            if (radFriction.SelectedIndex == 0)
                Total4 = 3;
            else if (radFriction.SelectedIndex == 1)
                Total4 = 2;
            else if (radFriction.SelectedIndex == 2)
                Total4 = 1;
            else
                Total4 = 0;
            //营养
            if (radNutrition.SelectedIndex == 0)
                Total5 = 4;
            else if (radNutrition.SelectedIndex == 1)
                Total5 = 3;
            else if (radNutrition.SelectedIndex == 2)
                Total5 = 2;
            else if (radNutrition.SelectedIndex == 3)
                Total5 = 1;
            else
                Total5 = 0;

            Sum = Total + Total1 + Total2 + Total3 + Total4 + Total5;
            txtScoreTotal.Text = Sum.ToString();
        }
        #endregion

        #region 保存
        private void btn_Preservation_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(dateE_AssDate.Text.Trim()))
                dateE_AssDate.DateTime = DateTime.Now;

            //更新分数到住院患者评估单
            record.Id = Id == "" ? 0 : Convert.ToInt32(Id);
            var ret2 = formService.SetNursingFormRecord(Newtonsoft.Json.JsonConvert.SerializeObject(record));

            var ret = formService.GetNursingFormRecord(PatientInfo.PATIENT_ID, PatientInfo.VISIT_ID, (int)FormType.RiskSore);

            string HuShiQianMing_ID1 = string.Empty;
            if (txtNurseId && !string.IsNullOrEmpty(txtNurse.Text) && txtNurse.Text.Equals(this.LoginUser.UserName))
                HuShiQianMing_ID1 = this.LoginUser.UserId;

            string HuShiZhangQianMing_ID1 = string.Empty;
            if (txtNurseZId && !string.IsNullOrEmpty(txtNurseZ.Text) && txtNurseZ.Text.Equals(this.LoginUser.UserName))
                HuShiZhangQianMing_ID1 = this.LoginUser.UserId;

            RiskSore rs = new RiskSore()
            {
                FormId = (int)FormType.RiskSore,//表单ID
                FormName = EnumHelper.GetDescription(FormType.RiskSore),//表单Name
                YuHou = (cheYuhou1.Checked ? 1 : 0) + "#" + (cheYuhou2.Checked ? 1 : 0) + "#" + (cheYuhou3.Checked ? 1 : 0) + "#" + (cheYuhou4.Checked ? 1 : 0) + "#" + (cheYuhou5.Checked ? 1 : 0) + "#" + (cheYuhou6.Checked ? 1 : 0),//预后
                HuanZheQianZi = txtjiashu.Text,//患者/家属签字
                YuHuanZheGuanXi = comboBoxEdityhzgx.Text,//与患者关系
                HuanZhePiFuQingGuang = txtSituation.Text,//患者皮肤情况
                PingGuRiQi = dateE_AssDate.DateTime.ToString("yyyy-MM-dd HH:mm:ss"),//评估日期
                GanJue = radFeel.EditValue == null ? "" : radFeel.EditValue.ToString(),//感觉
                ChaoShi = radDamp.EditValue == null ? "" : radDamp.EditValue.ToString(),//潮湿
                HuoDongLi = radActivity.EditValue == null ? "" : radActivity.EditValue.ToString(),//活动力
                YiDongLi = radMove.EditValue == null ? "" : radMove.EditValue.ToString(),//移动力
                MoChaLiHeJianQieLi = radFriction.EditValue == null ? "" : radFriction.EditValue.ToString(),//摩擦力和剪切力
                YingYang = radNutrition.EditValue == null ? "" : radNutrition.EditValue.ToString(),//营养
                TiWeiAnZhiYuBianHuan = (cheTiwei1.Checked ? 1 : 0) + "#" + (cheTiwei2.Checked ? 1 : 0) + "#" + (cheTiwei3.Checked ? 1 : 0) + "#" + (cheTiwei4.Checked ? 1 : 0) + "#" + (cheTiwei5.Checked ? 1 : 0) + "#" + (cheTiwei6.Checked ? 1 : 0),//体位安置与变换
                JianYaYongJuYuShiYong = (cheJianya1.Checked ? 1 : 0) + "#" + (cheJianya2.Checked ? 1 : 0) + "#" + (cheJianya3.Checked ? 1 : 0) + "#" + (cheJianya4.Checked ? 1 : 0),//减压用具与使用
                PiFuHuLi = (chePifu1.Checked ? 1 : 0) + "#" + (chePifu2.Checked ? 1 : 0) + "#" + (chePifu3.Checked ? 1 : 0) + "#" + (chePifu4.Checked ? 1 : 0) + "#" + (chePifu5.Checked ? 1 : 0) + "#" + (chePifu6.Checked ? 1 : 0),//皮肤护理
                YingYangZhiChi = (cheYingyang1.Checked ? 1 : 0) + "#" + (cheYingyang2.Checked ? 1 : 0) + "#" + (cheYingyang3.Checked ? 1 : 0) + "#" + (cheYingyang4.Checked ? 1 : 0),//营养支持

                HuShiQianMing = txtNurse.Text,   //护士签字
                HuShiQianMing_ID = HuShiQianMing_ID1,

                HuShiZhangQianMing = txtNurseZ.Text,//护士长签字
                HuShiZhangQianMing_ID = HuShiZhangQianMing_ID1,

                ZongFen = txtScoreTotal.Text//总分
            };
            if (string.IsNullOrEmpty(Id) && string.IsNullOrEmpty(rs.HuShiQianMing))
            {
                rs.HuShiQianMing = this.LoginUser.UserName;
                rs.HuShiQianMing_ID = this.LoginUser.UserId;
            }
            record.NursingFormData = XmlUtil.ObjectToXML(rs, Encoding.UTF8);
            record.FormId = (int)FormType.RiskSore;//表单ID
            record.FormName = EnumHelper.GetDescription(FormType.RiskSore);//表单Name
            record.PatientId = PatientInfo.PATIENT_ID;//住院号
            record.VisitId = PatientInfo.VISIT_ID;//住院次数
            record.PatientName = PatientInfo.PATIENT_NAME;//患者名称
            record.BedNo = PatientInfo.BED_NO;//床号
            record.DepartmentId = PatientInfo.DEPARTMENT_ID;//科室号
            record.DepartmentName = PatientInfo.DEPARTMENT_NAME;//科室名称
            record.AreaId = PatientInfo.NURSE_CELL_CODE;//病区编号
            record.AreaName = PatientInfo.NURSE_CELL_NAME;//病区名称
            record.AssessmentDate = dateE_AssDate.DateTime;//评估日期
            var ret1 = formService.SetNursingFormRecord(Newtonsoft.Json.JsonConvert.SerializeObject(record));
            if (ret1.S == true)
            {
                if (Base.ESSwitch.Equals("on"))
                {
                    //保存字段拼接成xml格式
                    string signXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><pingguriqi name=\"评估日期\">" + dateE_AssDate.Text + "</pingguriqi><zongfen name=\"总分\">" + txtScoreTotal.Text + "</zongfen><ganjue name=\"感觉\">" + radFeel.Text + "</ganjue>"
                        + "<chaoshi name=\"潮湿\">" + radDamp.Text + "</chaoshi><huodongli name=\"活动力\">" + radActivity.Text + "</huodongli><yidongli name=\"移动力\">" + radMove.Text + "</yidongli><friction name=\"摩擦力和剪切力\">" + radFriction.Text + "</friction>"
                        + "<yingyang name=\"营养\">" + radNutrition.Text + "</yingyang><tiwei name=\"体位安置与变换\">" + (cheTiwei1.Checked ? 1 : 0) + "#" + (cheTiwei2.Checked ? 1 : 0) + "#" + (cheTiwei3.Checked ? 1 : 0) + "#" + (cheTiwei4.Checked ? 1 : 0) + "#" + (cheTiwei5.Checked ? 1 : 0) + "#" + (cheTiwei6.Checked ? 1 : 0) + "</tiwei>"
                        + "<jianya name=\"减压用具与使用\">" + (cheJianya1.Checked ? 1 : 0) + "#" + (cheJianya2.Checked ? 1 : 0) + "#" + (cheJianya3.Checked ? 1 : 0) + "#" + (cheJianya4.Checked ? 1 : 0) + "</jianya>"
                        + "<pifu name=\"皮肤护理\">" + (chePifu1.Checked ? 1 : 0) + "#" + (chePifu2.Checked ? 1 : 0) + "#" + (chePifu3.Checked ? 1 : 0) + "#" + (chePifu4.Checked ? 1 : 0) + "#" + (chePifu5.Checked ? 1 : 0) + "#" + (chePifu6.Checked ? 1 : 0) + "</pifu>"
                        + "<yingyangzhichi name=\"营养支持\">" + (cheYingyang1.Checked ? 1 : 0) + "#" + (cheYingyang2.Checked ? 1 : 0) + "#" + (cheYingyang3.Checked ? 1 : 0) + "#" + (cheYingyang4.Checked ? 1 : 0) + "</yingyangzhichi>"
                        + "<hushiqianming name=\"护士签名\">" + txtNurse.Text + "</hushiqianming><hushizhangqianming name=\"护士长签名\">" + txtNurseZ.Text + "</hushizhangqianming>"
                        + "<yuhou name=\"预后\">" + (cheYuhou1.Checked ? 1 : 0) + "#" + (cheYuhou2.Checked ? 1 : 0) + "#" + (cheYuhou3.Checked ? 1 : 0) + "#" + (cheYuhou4.Checked ? 1 : 0) + "#" + (cheYuhou5.Checked ? 1 : 0) + "#" + (cheYuhou6.Checked ? 1 : 0) + "</yuhou>"
                        + "<jiashuqianming name=\"患者/家属签字\">" + txtjiashu.Text + "</jiashuqianming><yuhuanzheguanxi name=\"与患者关系\">" + comboBoxEdityhzgx.Text + "</yuhuanzheguanxi><huanzhepifuqingkuang name=\"患者皮肤情况\">" + txtSituation.Text + "</huanzhepifuqingkuang>";

                    string extraInfo = "<?xml version=\"1.0\" encoding=\"UTF-16\"?><root><sign_sys>{0}</sign_sys><title>{1}</title><patient_id>{2}</patient_id><patient_name>{3}</patient_name><emr_id>{4}</emr_id><emr_catalog>{5}</emr_catalog><his_id>{6}</his_id><event_no>{7}</event_no><visit_number>{8}</visit_number><dept_name>{9}</dept_name><prescribe_number>{10}</prescribe_number><prescribe_sub_number>{11}</prescribe_sub_number><prescribe_operation>医嘱操作（发送、校对、停止、作废）或门诊处方操作（发送）</prescribe_operation><radiotherapy_id>放疗号</radiotherapy_id><process_name>CT定位申请单审核</process_name><process_time>CT定位申请单审核时间</process_time><extend_value_1>备用扩展1</extend_value_1><extend_value_2>备用扩展2</extend_value_2><extend_value_3>备用扩展3</extend_value_3><extend_value_4>备用扩展4</extend_value_4><extend_value_5>备用扩展5</extend_value_5><extend_value_6>备用扩展6</extend_value_6><extend_value_7>备用扩展7</extend_value_7><extend_value_8>备用扩展8</extend_value_8><extend_value_9>备用扩展9</extend_value_9></root>";
                    extraInfo = string.Format(extraInfo, record.FormName + (record.Id > 0 ? "-更新" : "-新增"), record.FormName, record.PatientId, record.PatientName, record.Id, record.FormId, "", record.PatientId, record.VisitId, LoginUser.DepartmentName, record.PatientId, record.PatientId);
                    ElectronicSignature es = new ElectronicSignature(LoginUser);
                    bool res = es.GetElectronicSignatureImage(es, signXml, extraInfo, record.FormId.ToString(), record.FormName, PatientInfo.PATIENT_ID, PatientInfo.VISIT_ID);
                    if (!res) { MessageBox.Show("电子签名失败"); return; }
                }
                MessageBox.Show(ret1.M);
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(ret1.M);
            }
        }
        #endregion

        #region Change事件
        private void radFeel_SelectedIndexChanged(object sender, EventArgs e)
        {
            SunTotal();
        }

        private void radDamp_SelectedIndexChanged(object sender, EventArgs e)
        {
            SunTotal();
        }

        private void radActivity_SelectedIndexChanged(object sender, EventArgs e)
        {
            SunTotal();
        }

        private void radMove_SelectedIndexChanged(object sender, EventArgs e)
        {
            SunTotal();
        }

        private void radFriction_SelectedIndexChanged(object sender, EventArgs e)
        {
            SunTotal();
        }

        private void radNutrition_SelectedIndexChanged(object sender, EventArgs e)
        {
            SunTotal();
        }
        #endregion

        #region 取消
        private void btn_Cancle_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }
        #endregion

        bool txtNurseId = false;
        //护士签名
        private void txtNurse_DoubleClick(object sender, EventArgs e)
        {
            es.SearchElectronicSignatureImage(Base.ESSwitch, LoginUser, txtNurse, picElectronicSignature, txtNurse.Location);
            this.txtNurse.Text = this.LoginUser.UserName;
            txtNurseId = true;
        }
        bool txtNurseZId = false;
        //护士长签名
        private void txtNurseZ_DoubleClick(object sender, EventArgs e)
        {
            es.SearchElectronicSignatureImage(Base.ESSwitch, LoginUser, txtNurseZ, pictureBox1, txtNurseZ.Location);
            this.txtNurseZ.Text = this.LoginUser.UserName;
            txtNurseZId = true;
        }

        //护士签名
        private void hushiqianming_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtNurse.Text)) return;
            es.SearchElectronicSignatureImage(Base.ESSwitch, LoginUser, txtNurse, picElectronicSignature, txtNurse.Location);
            this.txtNurse.Text = this.LoginUser.UserName;
            txtNurseId = true;
        }

        //护士长签名
        private void hushizhangqianming_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtNurseZ.Text)) return;
            es.SearchElectronicSignatureImage(Base.ESSwitch, LoginUser, txtNurseZ, pictureBox1, txtNurseZ.Location);
            this.txtNurseZ.Text = this.LoginUser.UserName;
            txtNurseZId = true;
        }

    }
}
public class ArrayToObject
{
    public static Tb_User ArrayToLoginUser(string[] loginUser)
    {
        Tb_User LoginUser = new Tb_User();
        LoginUser.UserId = loginUser[0];
        LoginUser.UserName = loginUser[1];
        LoginUser.DepartmentCode = loginUser[2];
        LoginUser.DepartmentName = loginUser[3];
        LoginUser.JobTitle = loginUser[4];
        LoginUser.PositionTitle = loginUser[5];
        return LoginUser;
    }
    public static PatientInfo ArrayToPatientInfo(string[] patient)
    {
        PatientInfo patientInfo = new PatientInfo();
        patientInfo.PATIENT_ID = patient[0];//ID
        patientInfo.VISIT_ID = Convert.ToInt32(patient[1]);//住院次数
        patientInfo.PATIENT_NAME = patient[2];//姓名
        patientInfo.SEX = patient[3];  //性别
        patientInfo.AGE = patient[4];//年龄
        patientInfo.BED_NO = patient[5];//床号
        if (!string.IsNullOrEmpty(patient[6]))
            patientInfo.IN_DATE = Convert.ToDateTime(patient[6]);//入院时间
        if (!string.IsNullOrEmpty(patient[7]))
            patientInfo.IN_DEPARTMENT_DATE = Convert.ToDateTime(patient[7]);//入科时间
        patientInfo.DEPARTMENT_ID = patient[8];//科室ID
        patientInfo.DEPARTMENT_NAME = patient[9];//科室名称
        patientInfo.NURSE_CELL_CODE = patient[10];//病区ID
        patientInfo.NURSE_CELL_NAME = patient[11];//病区名称
        patientInfo.NATIONALS = patient[12];//民族
        patientInfo.EDUCATION = patient[13];//教育程度
        patientInfo.JOB = patient[14];//工作
        patientInfo.MARRIAGE = patient[15];//婚姻
        patientInfo.CONTACT_PHONE = patient[16];//联系电话
        patientInfo.DIAGNOSE = patient[17];//诊断信息
        return patientInfo;
    }
}